#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */


int main() {
    // Write your code here
    int n = 0;
    scanf("%d", &n);
    int arr[n];
    int i = 0;
    for (i = 0; i < n; i++)
    {
        scanf("%d", &arr[i]);
    }
    if (arr[0] <= arr[1])
    {
        for (i = 1; i < n - 1; i++)
        {
            if (arr[i] > arr[i + 1])
            {
                printf("No\n");
                break;
            }
        }
        if (i == n - 1)
        {
            printf("Yes\n");
        }
    }
    else if (arr[0] > arr[1])
    {
        for (i = 1; i < n - 1; i++)
        {
            if (arr[i] < arr[i + 1])
            {
                printf("No\n");
                break;
            }
        }
        if (i == n - 1)
        {
            printf("Yes\n");
        }
    }

    return 0;
}
